function ainme(state) {
    const first = document.querySelector('.first');
        const second = document.querySelector('.second');
        const sub = document.querySelector('.sub');
        if (state.navBar_acive) {
            first.style = 'transform: translateY(5.938px) rotate(45deg) translateZ(0px);'
            second.style = 'transform: rotate(-45deg) translateZ(0px);'
            sub.style = 'opacity: 0; transform: translateY(14.25px) translateZ(0px);'
        } else {
            first.style = 'transform: none;;'
            second.style = 'transform: none;'
            sub.style = 'opacity: 1; transform: none;;'
        }
}
export default {
    // 切换导航条
    changePage(state) {
        state.navBar_acive = !state.navBar_acive;
        ainme(state)

    },
    showVideo(state) {
        state.video_Show = true
        var body = document.querySelector('body')
        body.style = 'overflow: hidden; box-sizing: border-box; padding-right: 17px;'
    },
    CloseVideo(state) {
        state.video_Show = false
        var body = document.querySelector('body')
        body.style = ''
    },
    // 显示详情页，那个+
    showDetail_page(state) {
        state.detail_page = true
        var body = document.querySelector('body')
        body.style = 'overflow: hidden; box-sizing: border-box; padding-right: 17px;'
    },
    closeDetail_page(state) {
        state.detail_page = false
        var body = document.querySelector('body')
        body.style = ''
    },
    // 监听客户端的大小
    resize(state) {
        var container = document.querySelector(".page-container");
        var navbar = document.querySelector(".navBar");
        var container1 = document.querySelectorAll(".container");
        var vuexState = state;
        window.addEventListener("resize", function () {
            // console.log(this); 指向Window
            var MainBox = document.querySelector('.main-box')
            // console.log(MainBox.offsetWidth*0.005);
            vuexState.goodsWidth =  MainBox.offsetWidth;
            // console.log(state.goodsWidth);

            if (document.body.clientWidth < 1760) {
                container.className = "page-container desktop";
                navbar.className = "navBar desktop";
                // menu.className = "menu-bar desktop";
                for (let i = 0; i < container1.length; i++) {
                    container1[i].className = "container desktop";
                }
            }
            if (document.body.clientWidth < 1056) {
                container.className = "page-container tablet";
                navbar.className = "navBar tablet";
                // menu.className = "menu-bar tablet";
                for (let i = 0; i < container1.length; i++) {
                    container1[i].className = "container tablet";
                }
            }
            if (document.body.clientWidth < 788) {
                container.className = "page-container mobile";
                navbar.className = "navBar mobile";
                // menu.className = "menu-bar mobile";
                for (let i = 0; i < container1.length; i++) {
                    container1[i].className = "container mobile";
                }

            }
        });
    },
    changeActive(state,num){
        state.navBar_acive = !state.navBar_acive;
        state.active_num = num
        ainme(state)
        
        const pageContainer = document.querySelector('.page-container');
        const M_miaoxiang = document.querySelector('#mi-global-enjoy');
        // const M_zhineng = document.querySelector('#mi-global-smart'); 重复的样式没做
        const M_tongxue = document.querySelector('#mi-global-ecological');
        if(num == 0){
            pageContainer.scrollIntoView({
                behavior: "auto",  // 平滑过渡
                block:    "start"  // 上边框与视窗顶部平齐。默认值
            })
        }
        if(num == 1){
            M_miaoxiang.scrollIntoView({
                behavior: "auto",  // 平滑过渡
                block:    "start"  // 上边框与视窗顶部平齐。默认值
            })
        }
        if(num == 3){
            M_tongxue.scrollIntoView({
                behavior: "auto",  // 平滑过渡
                block:    "start"  // 上边框与视窗顶部平齐。默认值
            })
        }
        console.log(M_tongxue);
    }
}